package org.zfes.snowier.cloud.zbss.pmp.router.service.pm;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpModuleCreateDto;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpRequiresCreateDto;
import org.zfes.snowier.cloud.zbss.pmp.dto.PmpRequiresUpdateDto;
import org.zfes.snowier.cloud.zbss.pmp.service.IPmpRequiresService;
@Controller("org.zfes.snowier.cloud.zbss.pmp.router.service.pm.pmpRequiresController") 
@RequestMapping("/pmp/service/pm/pmpRequires")
public class PmpRequiresController extends BaseController {
	
	@Autowired
	private IPmpRequiresService pmpRequiresService;

	
	@RequestMapping(value="/createRoot", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public  @ResponseBody Object createRoot(Long projectId, String name){
		pmpRequiresService.createRoot(projectId,name);
	    return ajaxDoneSuccess("数据操作成功 ");
	}
	   
	@RequestMapping(value="/createModule", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public  @ResponseBody Object  createModule(PmpModuleCreateDto moduleCreateDto) {
		pmpRequiresService.createModule(moduleCreateDto);
	    return ajaxDoneSuccess("数据操作成功 ");
	}
	   	   
    @RequestMapping(value="/createPmpRequires", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createPmpRequires( PmpRequiresCreateDto pmpRequiresDto){
		pmpRequiresService.createPmpRequires(pmpRequiresDto);
    	return ajaxDoneSuccess("数据操作成功 ");
    }

    @RequestMapping(value="/updatePmpRequires", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updatePmpRequires(PmpRequiresUpdateDto requiresUpdateDto){
		pmpRequiresService.updatePmpRequires( requiresUpdateDto);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    @RequestMapping(value="/updateModuleName", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateModuleName(Long id,String newname){
		pmpRequiresService.updateModuleName(id, newname);
		return ajaxDoneSuccess("数据操作成功 ");
    }

    @RequestMapping(value="/updateOrderNum", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateOrderNum(Long id, Integer orderNum){
		pmpRequiresService.updateOrderNum(id, orderNum);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/deletePmpRequires", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletePmpRequires(Long id){
		pmpRequiresService.setPmpRequiresStatus(id, Byte.valueOf("-1"));
		return ajaxDoneSuccess("数据操作成功 ");
    }

}